<!-- 普通的table表格 第一列带有index序号-->
<template>
  <div class="svt-table">
    <el-table
      :max-height="maxHeight"
      :cell-style="setCellStyle"
      :data="tableData"
      style="width: 100%"
      class="svt-table-wrapper"
      :stripe="true"
      border
      @row-dblclick="rowDoubleClick"
    >
      <el-table-column type="index" :index="setTableIndex" width="50" label=" "></el-table-column>
      <el-table-column
        v-for="(item, index) in tableHeaderData"
        :key="index"
        :label="item.name"
        :property="item.property"
      ></el-table-column>
    </el-table>
  </div>
</template>
<script>
export default {
  name: "svt-table",
  props: {
    tableHeaderData: {
      type: Array,
      default: () => []
    },
    tableData: {
      type: Array,
      default: () => []
    },
    startIndex: {
      type: Number,
      default: 0
    },
    maxHeight: {
      type: [Number, String],
      default: 700
    },
    dbclickPermit: {
      type: Boolean,
      default: true
    },
    routerPath: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      tableIndex: 1
    };
  },
  computed: {},
  created() {},
  methods: {
    setTableIndex(index) {
      return this.startIndex + index + 1;
    },
    setCellStyle(params) {
      if (params.columnIndex === 1) return (params.column.minWidth = 120);
      if(params.columnIndex === 7) return (params.column.minWidth = 100)
      if(params.columnIndex === 8) return (params.column.minWidth = 100)
    },
    rowDoubleClick(row, column, event) {
      this.$store.dispatch('addLogDetailInfo', row)
      this.$router.push({path: this.routerPath})
    }
  },
  components: {}
};
</script>
<style lang='scss'>
.svt-table {
  .svt-table-wrapper {
    td,
    th {
      text-align: center;
    }
  }
}
</style>



